package com.biz.primus.base.vo.commodity;

import com.biz.primus.base.enums.SaleChannel;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;

import java.io.Serializable;

/**
 * User: jiangnan
 * Description:
 */
@Data
@ApiModel("商品基本信息 对应商品Ro中的内容")
public class ProductBaseVo implements Serializable {

    @ApiModelProperty("商品Id")
    private Long productId;

    @ApiModelProperty("商品编码")
    private String productCode;

    @ApiModelProperty("商品类型 对应VendorType")
    private Integer productType;

    @ApiModelProperty("商品名")
    private String name;

    @ApiModelProperty("商品 Logo")
    private String logo;

    @ApiModelProperty("商品主图,逗号分隔")
    private String images;

    @ApiModelProperty("商品详情图片,逗号分隔")
    private String introImages;

    @ApiModelProperty("商品箱规中 需要在前端展示瓶箱切换的数量")
    private Integer packageNumber;

    /**
     * @see SaleStatus
     */
    @ApiModelProperty("上下架状态")
    private Integer saleStatus;

    /**
     * @see SaleStatus
     */
    @ApiModelProperty("web渠道")
    private Integer webSaleStatus;

    /**
     * @see SaleStatus
     */
    @ApiModelProperty("app渠道")
    private Integer appSaleStatus;

    @ApiModelProperty("商品重量")
    private Integer weight;

    @ApiModelProperty("分类id")
    private Long categoryId;

    @ApiModelProperty("品牌id")
    private Long brandId;

    @ApiModelProperty("商品品牌名称")
    private String brandName;

    @ApiModelProperty("分类名称")
    private String categoryName;

    public SaleStatus saleStatus(){
        return SaleStatus.valueOf(this.saleStatus);
    }

    public SaleStatus saleStatus(SaleChannel saleChannel){
        if (saleChannel == SaleChannel.ALL){
            return this.saleStatus();
        }
        if (saleChannel == SaleChannel.APP){
            if (this.saleStatus()==SaleStatus.ON_SALE&&appSaleStatus==SaleStatus.ON_SALE.getValue()){
                return SaleStatus.ON_SALE;
            }else {
                return SaleStatus.OFF_SALE;
            }
        }else if (saleChannel == SaleChannel.WEB){
            if (this.saleStatus()==SaleStatus.ON_SALE&&webSaleStatus==SaleStatus.ON_SALE.getValue()){
                return SaleStatus.ON_SALE;
            }else {
                return SaleStatus.OFF_SALE;
            }
        }
        return null;
    }

}
